package com.mz.ozy.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mz.ozy.R;
import com.mz.ozy.bean.HomeBean;
import com.mz.ozy.utils.glideUtils.GlideUtils;

import java.util.Arrays;
import java.util.List;

/**
 *
 */

public class HomeCoinsAdapter extends BaseQuickAdapter<HomeBean.ProductlistBean, BaseViewHolder> {
    public HomeCoinsAdapter(List<HomeBean.ProductlistBean> data) {
        super(R.layout.item_home_detail, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, HomeBean.ProductlistBean item) {
        helper.setText(R.id.tv_title, String.valueOf(item.getTradename()));
        List<String> list = Arrays.asList(item.getImg_zt().split(","));

        String price = "";
        if (!TextUtils.isEmpty(item.getPrice()) && Double.parseDouble(item.getPrice()) != 0.00) {
            price += item.getPrice();
            price += "KT";
        }
        if (!TextUtils.isEmpty(item.getMarket_price()) && Double.parseDouble(item.getMarket_price()) != 0.00) {
            if (!TextUtils.isEmpty(price)) {
                price += "+";
                price += item.getMarket_price();
                price += "消费积分";
            } else {
                price += item.getMarket_price();
                price += "消费积分";
            }
        }
        if (TextUtils.isEmpty(price)) {
            price = "0.00KT";
        }
        helper.setText(R.id.tv_price, price);
        ImageView imageView = helper.itemView.findViewById(R.id.image);
        GlideUtils.loadImg(mContext, imageView, list.get(0));
        helper.addOnClickListener(R.id.ll_item);
    }


}
